package com.mcflywzx.airhockey.objects;

import static android.opengl.GLES20.GL_POINTS;
import static android.opengl.GLES20.GL_TRIANGLE_FAN;
import static android.opengl.GLES20.glDrawArrays;

import java.util.List;

import com.mcflywzx.airhockey.Constants;
import com.mcflywzx.airhockey.data.VertexArray;
import com.mcflywzx.airhockey.objects.ObjectBuilder.DrawCommand;
import com.mcflywzx.airhockey.objects.ObjectBuilder.GeneratedData;
import com.mcflywzx.airhockey.programs.ColorShaderProgram;
import com.mcflywzx.airhockey.util.Geometry.Cylinder;
import com.mcflywzx.airhockey.util.Geometry.Point;

public class Mallet {

	private static final int POSITION_COMPONENT_COUNT = 3;
	
	public final float R, H;
	
	private final VertexArray vA;
	private final List<DrawCommand> drawList;
	
	public Mallet(float R, float H, int numPointsAroundMallet) {
		GeneratedData gD = ObjectBuilder.createMallet(new Point(0f, 0f, 0f), R, H, numPointsAroundMallet);
		
		this.R = R;
		this.H = H;
		
		vA = new VertexArray(gD.vD);
		drawList = gD.drawList;
	}
	
	public void bindData(ColorShaderProgram cP) {
		vA.setVertexAttribPointer(0, cP.getPositionAttributeLocation(), POSITION_COMPONENT_COUNT, 0);
	}
	
	public void draw() {
		for(DrawCommand dC : drawList) {
			dC.draw();
		}
	}
}
